/*
    aQtLow - an Arduino interface.
    Copyright (C) 2011  Dee Wykoff

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef REGISTER_H
#define REGISTER_H

#include <QObject>

#include <QString>

class REGISTER : public QObject
{
        Q_OBJECT
public:
    explicit REGISTER(QObject *parent = 0);
    QString Name, Description, Short, Units, Page, Text;
    double PrcWrite, PrcLow, PrcHigh, PrcValue, Value, IntfcLow, IntfcHigh, IntfcMin, IntfcMax, LogFilter, LastLogValue;
    bool FirstRead, IsConfigured, IsLogged, WriteRequest;
    qint64 LastLogTime;

signals:
    void Changed();
    void Changed(double Value);
    void Changed(QString Text);

public slots:
    void FromPrc(double PrcRead);
    void Set(double WriteValue);
    void Set(QString Text);
    void Reset();
    void Inc(double Increment);
    void Dec(double Decrement);
    QString TextRounded(int Decimals);
    double ValueRounded(int Decimals);

private slots:
    void CombinedWrite(double WriteValue);

};

double Rescale(double In, double InLow, double InHigh, double OutLow, double OutHigh);
double Clamp(double In, double Low, double High);


#endif // REGISTER_H



